function hfile = fif_ReadInfoHeaders(hfile, ispec)
% FIF::ReadInfoHeaders  - read info headers into memory
%
% FORMAT:       fif.ReadInfoHeaders([ispec])
%
% Input fields:
%
%       ispec       optional list of header block types to read,
%                   default: [101, 900]

% Version:  v0.7b
% Build:    7083009
% Date:     Aug-30 2007, 9:26 AM CEST
% Author:   Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% argument check
if nargin < 1 || ...
    numel(hfile) ~= 1 || ...
   ~isBVQXfile(hfile, 'fif')
    error( ...
        'BVQXfile:BadArgument', ...
        'Invalid call to %s.', ...
        mfilename ...
    );
end
if nargin < 2 || ...
   ~isa(ispec, 'double') || ...
    isempty(ispec)
    ispec = [101, 900];
else
    ispec = unique(fix(ispec(:)'));
    ispec(isinf(ispec) | isnan(ispec) | ispec < 1 | ispec > 16777216) = [];
    if isempty(ispec)
        ispec = [101, 900];
    end
end

% get object reference
bc = bvqxfile_getcont(hfile.L);

% get FIF
fif = bc.FIFStructure;
lup = fif.BlockLookup;

% load blocks
bli = zeros(1, 0);
for ic = ispec
    bli = [bli, find(lup(1, :) == ic)];
end
for buc = bli
    fif = fifio(fif, 'readelem', lup(2, buc):lup(3, buc));
end

% put back into object
bc.FIFStructure = fif;
bvqxfile_setcont(hfile.L, bc);
